<template>
    <a-radio-group class="w-full" v-model:value="value" :placeholder="props.placeholder" :options="options" @change="inputVal" />
</template>
<script setup>
const emits = defineEmits(["update:value", "change"]);
const props = defineProps({
    value: undefined,
    placeholder: {
        type: String,
        default: "请输入",
    },
    options: {
        type: Array,
        default: "",
    },
});

const state = reactive({
    value: undefined,
    options: [],
});

const inputVal = () => {
    emits("update:value", state.value);
};
watch(
    () => props.value,
    (newVal, oldVal) => {
        if (newVal === null || newVal === "" || newVal === undefined) {
            state.value = undefined;
        } else {
            state.value = newVal;
        }
    },
    { deep: true, immediate: true }
);
watch(
    () => props.options,
    (newVal, oldVal) => {
        state.options = XEUtils.clone(newVal, true);
    },
    { deep: true, immediate: true }
);
defineExpose({});
const { value, options } = toRefs(state);
</script>

